﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package reprise.data {

    public class URL {

        protected var m_host:String;// = ""
        protected var m_port:int;
        protected var m_queryObject:Object;
        protected var m_user:String;
        protected var m_fragment:String;
        protected var m_password:String;
        protected var m_query:String;
        protected var m_path:String;
        protected var m_scheme:String;

        protected static const URL_PARSER:RegExp = new RegExp((((((((("(?:" + "(?P<protocol>[a-z]*(?=[:]//))") + "[:]//(?P<credentials>[^@]*(?=@))?@?") + "(?P<host>[^/:]*(?=[:/]|$))?") + "[:]?(?P<port>(?<=[:])[0-9]*)?") + "|)") + "(?P<path>[^?]+)?") + "(?:[?](?P<query>[^#]+))?") + "(?:[#](?P<anchor>.*))?"), "");

        public function URL(_arg1:String=null){
            if (_arg1){
                parseURL(_arg1);
            };
        }
        public function isAbsoluteURL():Boolean{
            return ((m_path.indexOf("/") == 0));
        }
        public function setPort(_arg1:int):void{
            m_port = _arg1;
        }
        public function setQuery(_arg1:String):void{
            var _local3:String;
            var _local4:Array;
            m_query = _arg1;
            m_queryObject = {};
            var _local2:Array = m_query.split("&");
            for each (_local3 in _local2) {
                if (((!(_local3)) || (!(_local3.length)))){
                } else {
                    _local4 = _local3.split("=");
                    m_queryObject[_local4[0]] = _local4[1];
                };
            };
        }
        public function port():int{
            return (m_port);
        }
        public function queryObject():Object{
            return (m_queryObject);
        }
        public function user():String{
            return (m_user);
        }
        public function setUser(_arg1:String):void{
            m_user = _arg1;
        }
        public function query():String{
            return (m_query);
        }
        public function fragment():String{
            return (m_fragment);
        }
        public function setFragment(_arg1:String):void{
            m_fragment = _arg1;
        }
        public function isFileURL():Boolean{
            return ((m_scheme == "file"));
        }
        public function password():String{
            return (m_password);
        }
        public function setPassword(_arg1:String):void{
            m_password = _arg1;
        }
        public function scheme():String{
            return ((m_scheme) ? (m_scheme + "://") : null);
        }
        public function setScheme(_arg1:String):void{
            if (_arg1.indexOf("://") != -1){
                _arg1 = _arg1.substr(0, _arg1.indexOf("://"));
            };
            m_scheme = _arg1;
        }
        public function host():String{
            return (m_host);
        }
        public function valueOf():String{
            var _local1 = "";
            if (m_scheme){
                _local1 = (_local1 + (m_scheme + "://"));
            };
            if (m_user){
                _local1 = (_local1 + m_user);
                if (m_password){
                    _local1 = (_local1 + (":" + m_password));
                };
                _local1 = (_local1 + "@");
            };
            if (m_host){
                _local1 = (_local1 + m_host);
                if (!isNaN(m_port)){
                    _local1 = (_local1 + (":" + m_port));
                };
                if (m_path.charAt(0) != "/"){
                    _local1 = (_local1 + "/");
                };
            };
            if (m_path){
                _local1 = (_local1 + m_path);
            };
            if (m_query){
                _local1 = (_local1 + ("?" + m_query));
            };
            if (m_fragment){
                _local1 = (_local1 + ("#" + m_fragment));
            };
            return (_local1);
        }
        public function setHost(_arg1:String):void{
            m_host = _arg1;
        }
        public function toString():String{
            return (("[URL] " + valueOf()));
        }
        protected function parseURL(_arg1:String):void{
            var _local2:Array = URL_PARSER.exec(_arg1);
            m_scheme = _local2["protocol"];
            var _local3:Array = _local2["credentials"].split(":");
            m_user = _local3[0];
            m_password = ((_local3[1]) || (""));
            m_host = _local2["host"];
            m_port = parseInt(_local2["port"]);
            m_path = _local2["path"];
            setQuery(_local2["query"]);
            m_fragment = _local2["anchor"];
        }
        public function path():String{
            return (m_path);
        }
        public function setPath(_arg1:String):void{
            m_path = _arg1;
        }

    }
}//package reprise.data 
